package queueDemo;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

public class Demo2 {
    public static void main(String[] args) {
        BlockingQueue<Integer> queue2 = new ArrayBlockingQueue<Integer>(10);
        Thread t1 = new Thread(()->{
            while(true){
                try {
                    Thread.sleep(1000);
                    queue2.add(1);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

            }

        });
        Thread t2 = new Thread(()->{
            while(true){
//                    queue2.remove();
                queue2.element();
            }
        });
        t1.start();
        t2.start();
    }
}

